<html>
<head><meta charset="utf-8"><title>chalk:  introduce a `Visit` trait to go with `Fold` #333 · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.3A.20.20introduce.20a.20.60Visit.60.20trait.20to.20go.20with.20.60Fold.60.20.23333.html">chalk:  introduce a `Visit` trait to go with `Fold` #333</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="189442031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%3A%20%20introduce%20a%20%60Visit%60%20trait%20to%20go%20with%20%60Fold%60%20%23333/near/189442031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Suhas Hebbar <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.3A.20.20introduce.20a.20.60Visit.60.20trait.20to.20go.20with.20.60Fold.60.20.23333.html#189442031">(Mar 01 2020 at 18:09)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> , In  <a href="https://github.com/rust-lang/chalk/issues/333#issuecomment-593024680" target="_blank" title="https://github.com/rust-lang/chalk/issues/333#issuecomment-593024680">#333</a> by</p>
<blockquote>
<p>Just want to clarify that not all Fold impls will be Visitors.</p>
</blockquote>
<p>Do you mean to say some <code>Fold</code> impls will be changed to impl <code>Visit</code> while others will remain unchanged?<br>
This confused me a bit as I had thought <code>Visit</code>, <code>Visitor</code> and <code>VisitResult</code> would be more generic and reusable replacements of Fold and Folder.</p>
<p>Or did you mean to say that <br>
<code>impl&lt;...&gt; Visit for Foo&lt;...&gt; {...}</code><br>
doesn't mean there would be a corresponding <code>visitor.visit_foo(...)</code> as some Fold impls recursively call fold_with/super_fold_with (or visit_with if this change is made)?</p>



<a name="189452062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%3A%20%20introduce%20a%20%60Visit%60%20trait%20to%20go%20with%20%60Fold%60%20%23333/near/189452062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.3A.20.20introduce.20a.20.60Visit.60.20trait.20to.20go.20with.20.60Fold.60.20.23333.html#189452062">(Mar 01 2020 at 23:08)</a>:</h4>
<p><span class="user-mention silent" data-user-id="267130">Suhas Hebbar</span> <a href="#narrow/stream/144729-wg-traits/topic/chalk.3A.20.20introduce.20a.20.60Visit.60.20trait.20to.20go.20with.20.60Fold.60.20.23333/near/189442031" title="#narrow/stream/144729-wg-traits/topic/chalk.3A.20.20introduce.20a.20.60Visit.60.20trait.20to.20go.20with.20.60Fold.60.20.23333/near/189442031">said</a>:</p>
<div class="codehilite"><pre><span></span>Do you mean to say some `Fold` impls will be changed to impl `Visit` while others will remain unchanged?
</pre></div>


<p>Yes, basically. But if <code>Visit</code>/<code>Visitor</code> ends up being general enough to cover the use cases of <code>Folder</code>/<code>Folder</code>, then I suppose that's okay too</p>



<a name="189452578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%3A%20%20introduce%20a%20%60Visit%60%20trait%20to%20go%20with%20%60Fold%60%20%23333/near/189452578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.3A.20.20introduce.20a.20.60Visit.60.20trait.20to.20go.20with.20.60Fold.60.20.23333.html#189452578">(Mar 01 2020 at 23:22)</a>:</h4>
<p>Though, looking at <code>Fold</code> and <span class="user-mention" data-user-id="116009">@nikomatsakis</span>'s proposed <code>Visit</code>, it's very possible they can be completely merged</p>



<a name="189508881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%3A%20%20introduce%20a%20%60Visit%60%20trait%20to%20go%20with%20%60Fold%60%20%23333/near/189508881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.3A.20.20introduce.20a.20.60Visit.60.20trait.20to.20go.20with.20.60Fold.60.20.23333.html#189508881">(Mar 02 2020 at 16:37)</a>:</h4>
<p>I don't think they can be merged</p>



<a name="189508906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%3A%20%20introduce%20a%20%60Visit%60%20trait%20to%20go%20with%20%60Fold%60%20%23333/near/189508906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.3A.20.20introduce.20a.20.60Visit.60.20trait.20to.20go.20with.20.60Fold.60.20.23333.html#189508906">(Mar 02 2020 at 16:37)</a>:</h4>
<p>The <code>Visitor</code> impl defines the "Result" type for <code>Visit</code>, but it has to be the same across all types that are visited</p>



<a name="189508933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%3A%20%20introduce%20a%20%60Visit%60%20trait%20to%20go%20with%20%60Fold%60%20%23333/near/189508933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.3A.20.20introduce.20a.20.60Visit.60.20trait.20to.20go.20with.20.60Fold.60.20.23333.html#189508933">(Mar 02 2020 at 16:37)</a>:</h4>
<p>whereas for <code>Fold</code>, the result type is defined by the type being visited (and not the <code>Folder</code>)</p>



<a name="189508941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%3A%20%20introduce%20a%20%60Visit%60%20trait%20to%20go%20with%20%60Fold%60%20%23333/near/189508941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.3A.20.20introduce.20a.20.60Visit.60.20trait.20to.20go.20with.20.60Fold.60.20.23333.html#189508941">(Mar 02 2020 at 16:37)</a>:</h4>
<p>(Also, side note, we should rename <code>Fold</code> to <code>Map</code> ..)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>